VERSION 5.00
Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "RICHTX32.OCX"
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form BackupFrm 
   BackColor       =   &H8000000C&
   Caption         =   "Back Up Confirmation"
   ClientHeight    =   3090
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   4875
   BeginProperty Font 
      Name            =   "MS Sans Serif"
      Size            =   8.25
      Charset         =   0
      Weight          =   700
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   LinkTopic       =   "Form1"
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   MouseIcon       =   "backup_form.frx":0000
   ScaleHeight     =   2075.218
   ScaleMode       =   0  'User
   ScaleWidth      =   12166.53
   Visible         =   0   'False
   WindowState     =   2  'Maximized
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   375
      Left            =   480
      Top             =   720
      Visible         =   0   'False
      Width           =   1815
      _ExtentX        =   3201
      _ExtentY        =   661
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "Adodc1"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin VB.PictureBox Picture1 
      Appearance      =   0  'Flat
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H80000008&
      Height          =   3375
      Left            =   7440
      ScaleHeight     =   3345
      ScaleWidth      =   4665
      TabIndex        =   11
      Top             =   2760
      Width           =   4695
      Begin VB.TextBox Text3 
         Height          =   285
         IMEMode         =   3  'DISABLE
         Left            =   2160
         PasswordChar    =   "*"
         TabIndex        =   0
         Top             =   360
         Width           =   2295
      End
      Begin VB.CommandButton Command2 
         Caption         =   "Cancel"
         Height          =   375
         Left            =   2520
         TabIndex        =   4
         Top             =   2280
         Width           =   975
      End
      Begin VB.CommandButton Command1 
         Caption         =   "Confirm"
         Height          =   375
         Left            =   1080
         TabIndex        =   3
         Top             =   2280
         Width           =   975
      End
      Begin VB.TextBox Text2 
         Height          =   285
         IMEMode         =   3  'DISABLE
         Left            =   2160
         PasswordChar    =   "*"
         TabIndex        =   2
         Top             =   1560
         Width           =   2295
      End
      Begin VB.TextBox Text1 
         Height          =   285
         IMEMode         =   3  'DISABLE
         Left            =   2160
         PasswordChar    =   "*"
         TabIndex        =   1
         Top             =   960
         Width           =   2295
      End
      Begin VB.Label Label5 
         Caption         =   "Enter Password to Backup Ur Files"
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   -1  'True
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   120
         TabIndex        =   10
         Top             =   240
         Width           =   4455
      End
      Begin VB.Label Label4 
         Caption         =   "Enter Old Password"
         Height          =   255
         Left            =   120
         TabIndex        =   9
         Top             =   375
         Width           =   1695
      End
      Begin VB.Label Label3 
         Caption         =   "Change Password"
         Height          =   255
         Left            =   3000
         MouseIcon       =   "backup_form.frx":030A
         MousePointer    =   99  'Custom
         TabIndex        =   5
         Top             =   2880
         Width           =   1575
      End
      Begin VB.Label Label2 
         Caption         =   "Re-Enter Password"
         Height          =   255
         Left            =   120
         TabIndex        =   8
         Top             =   1575
         Width           =   1695
      End
      Begin VB.Label Label1 
         Caption         =   "Enter Password"
         Height          =   255
         Left            =   120
         TabIndex        =   7
         Top             =   975
         Width           =   1575
      End
   End
   Begin RichTextLib.RichTextBox RichTextBox1 
      Height          =   375
      Left            =   3240
      TabIndex        =   6
      Top             =   4200
      Visible         =   0   'False
      Width           =   1575
      _ExtentX        =   2778
      _ExtentY        =   661
      _Version        =   393217
      Enabled         =   -1  'True
      TextRTF         =   $"backup_form.frx":0614
   End
End
Attribute VB_Name = "BackupFrm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim pass As String
Dim db As Connection
Dim rs As Recordset
Dim rs1 As Recordset
Dim mon(11) As String
Private Sub Command1_Click()
If Label3.Visible = True Then
ret = decrypt(LTrim(RichTextBox1.Text))
If Text1.Text = ret Then
'-------------------------------------------Making the backup directory and copying database file into the folder which is newly created-------------------------------------------
If (Dir(App.Path & "\" & (Year(Now) - 1) & "-" & Year(Now), vbDirectory)) <> ((Year(Now) - 1) & "-" & Year(Now)) Then
MkDir (App.Path & "\" & (Year(Now) - 1) & "-" & Year(Now))
FileCopy App.Path & "\Jeevan.mdb", App.Path & "\" & (Year(Now) - 1) & "-" & (Year(Now)) & "\Jeevan.mdb"
FileCopy App.Path & "\PlanA.mdb", App.Path & "\" & (Year(Now) - 1) & "-" & (Year(Now)) & "\PlanA.mdb"
FileCopy App.Path & "\PlanC.mdb", App.Path & "\" & (Year(Now) - 1) & "-" & (Year(Now)) & "\PlanC.mdb"
'-------------------------------------------Clearing the data from agentinfo and salary tables for the purpose of annual year-------------------------------------------
Call database
mon(0) = "Jan"
mon(1) = "Feb"
mon(2) = "Mar"
mon(3) = "Apr"
mon(4) = "May"
mon(5) = "Jun"
mon(6) = "Jul"
mon(7) = "Aug"
mon(8) = "Sep"
mon(9) = "Oct"
mon(10) = "Nov"
mon(11) = "Dec"
While Not rs.EOF
rs1.Open "Update AgentInfo Set Perform=0 where CodeNo='" & rs.Fields(0) & "'", db
For i = 0 To 11
rs1.Open "Update Salary Set " & mon(i) & "1 = 0, " & mon(i) & "2 = 0, " & mon(i) & "3 = 0, " & mon(i) & "4 = 0, tds=0, tdsmonth='' where CodeNo='" & rs.Fields(0) & "'", db
Next
rs.MoveNext
Wend
MsgBox "Updation Finished Successfully"
End If
End If
Else
'----------------------------------------------------------------------Changing password--------------------------------------------------------------------------------------
ret = encrypt(Text3.Text)
If Trim(RichTextBox1.Text) = Trim(ret) And Text1.Text = Text2.Text Then
RichTextBox1.Text = encrypt(Text1.Text) + " "
RichTextBox1.SaveFile (App.Path & "\backup.mkp")
MsgBox "Password Changed Successfully"
Label3.Visible = True
Label4.Visible = False
Text3.Visible = False
Label5.Visible = True
Else
MsgBox "Passwords are Mismatching"
End If
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End If
Command1.Enabled = False
End Sub
Private Sub Command2_Click()
'-------------------------------------------Action performed when cancel button is clicked--------------------------------------------------------------------------------------
If Label3.Visible = False Then
Label3.Visible = True
Label4.Visible = False
Text3.Visible = False
Label5.Visible = True
Else
Unload Me
End If
End Sub
Private Sub Form_Load()
Label4.Visible = False
Text3.Visible = False
Command1.Enabled = False
RichTextBox1.LoadFile (App.Path & "\backup.mkp")
End Sub
Private Sub Label3_Click()
'-------------------------------------------To view Change Password module--------------------------------------------------------------------------------------
Label4.Visible = True
Text3.Visible = True
Label3.Visible = False
Label5.Visible = False
End Sub
Private Sub Text2_LostFocus()
'-------------------------------------------Checking whether entered passwords are correct or not--------------------------------------------
If Text1 <> "" And Text2 <> "" Then
If Text1.Text <> Text2.Text Then
MsgBox ("Enter Corret Password in both Field")
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
Else
Command1.Enabled = True
Command1.SetFocus
End If
End If
End Sub
Public Function encrypt(word As String) As String
pass = ""
For i = 1 To Len(word)
pass = pass + str(Asc(Mid(word, i, 1)))
Next
encrypt = pass
End Function
Public Function decrypt(word As String) As String
pass = ""
p = ""
For i = 1 To Len(word)
If Mid(word, i, 1) <> " " Then
pass = pass + Mid(word, i, 1)
Else
p = p + Chr(pass)
pass = ""
End If
Next
decrypt = p
End Function
Private Sub database()
Set db = New Connection
db.Provider = "Microsoft.Jet.OLEDB.4.0"
db.Open App.Path & "\Jeevan.mdb"
Set rs = New Recordset
rs.CursorLocation = adUseServer
rs.CursorType = adOpenKeyset
rs.LockType = adLockOptimistic
rs.Open "select codeno from AgentInfo", db
Set rs1 = New Recordset
rs1.CursorLocation = adUseServer
rs1.CursorType = adOpenKeyset
rs1.LockType = adLockOptimistic
End Sub
